.\"
.\" FreeBSD pkg - a next generation package for the installation and
.\" maintenance of non-core utilities.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\"
.\"     @(#)pkg.8
.\"
.Dd May 14, 2019
.Dt PKG-UPGRADE 8
.Os
.Sh NAME
.Nm "pkg upgrade"
.Nd perform upgrades of package software distributions
.Sh SYNOPSIS
.Nm
.Op Fl fInFqUy
.Op Fl r Ar reponame
.Op Fl Cgix
.Op Ar <pkg-origin|pkg-name|pkg-name-version> ...
.Pp
.Nm
.Op Cm --{force,no-install-scripts,dry-run,fetch-only}
.Op Cm --{quiet,no-repo-update,yes}
.Op Cm --repository Ar reponame
.Op Cm --{case-sensitive,glob,case-insensitive,regex}
.Op Ar <pkg-origin|pkg-name|pkg-name-version> ...
.Sh DESCRIPTION
.Nm
is used for upgrading packaged software distributions.
.Pp
.Nm
compares the versions of all or specific packages installed on the system
to what is available in the configured package repositories.
Any out of date packages are added to a work list for processing.
The difference to
.Xr pkg-install 8
is that
.Nm
tries to upgrade dependencies of packages matched as well while
.Xr pkg-install 8
is more conservative during dependencies upgrade.
Moreover,
.Nm
will not install new packages, except as required to fulfil dependencies of
the packages listed on the command line.
A caller should ensure that patterns specified as arguments have installed
candidates for matching.
If the
.Fl f
(force) flag is given, all installed packages are added to the work
list.
.Pp
The package metadata downloaded from the repositories is then examined
for each of the packages in the work list, and any missing
dependencies are added to the work list as install jobs.
Such implicitly added packages are flagged as candidates for
autoremoval.
See
.Xr pkg-autoremove 8
for details.
.Pp
Autoremoval flags are sticky, and will persist over reinstallation or
upgrade of the packages concerned, even if subsequently the packages
are named explicitly on a command line.
See
.Xr pkg-query 8
for finding the autoremoval status of a package, and
.Xr pkg-set 8
for modifying it.
.Pp
Where a package on the work list supplies a shared library, and that
library has been updated, all packages requiring that shared library
will also be added to the work list as reinstallation jobs.
.Pp
The work list is sorted into dependency order and
.Nm
will present it to the user for approval before proceeding, unless
overridden by the
.Fl y
option or the
.Cm ASSUME_ALWAYS_YES
setting in
.Pa pkg.conf .
.Pp
Packages are fetched from the repositories into the local package
cache if they are not already present, or if the checksum of the
cached package file differs from the one in the repository.
Packages may be downloaded from any of the repositories mentioned
in
.Xr pkg.conf 5
or in the files in
.Pa /usr/local/etc/pkg/repo .
See
.Xr pkg-repository 5
for details.
.Pp
Package repository catalogues will be automatically updated whenever
.Nm
is run by a user ID with write access to the package database,
unless disabled by the
.Fl U
flag or setting
.Cm REPO_AUTOUPDATE
to
.Sy NO
in
.Xr pkg.conf 5 .
.Pp
Finally, the work list is executed in dependency order.
Package reinstall or update jobs are processed by removing the currently
installed package and immediately installing the replacement.
New dependencies are processed as installation jobs as part of the
work list.
.Sh OPTIONS
The following options are supported by
.Nm :
.Bl -tag -width repository
.It Fl C , Cm --case-sensitive
Make the standard or the regular expression
.Fl ( x )
matching against
.Ar pkg-name
case sensitive.
.It Fl F , Cm --fetch-only
Do not perform installation of packages, merely fetch packages that should be
upgraded and detect possible conflicts.
.It Fl f , Cm --force
Force the reinstallation or upgrade of the whole set of packages.
.It Fl g , Cm --glob
Treat the package names as shell glob patterns.
.It Fl I , Cm --no-install-scripts
If any installation scripts (pre-install or post-install) or deinstallation
scripts (pre-deinstall or post-deinstall) exist for a given package, do not
execute them.
.It Fl i , Cm --case-insensitive
Make the standard or the regular expression
.Fl ( x )
matching against
.Ar pkg-name
case insensitive.
This is the default, unless modified by setting
.Ev CASE_SENSITIVE_MATCH
to true in
.Pa pkg.conf .
.It Fl n , Cm --dry-run
Dry-run mode: show what packages have updates available, but do not perform
any upgrades.
Repository catalogues will be updated as usual unless the
.Fl U
option is also given.
.It Fl q , Cm --quiet
Force quiet output, except when
.Fl n
is used, where a summary of the work list is always displayed.
.It Fl r Ar reponame , Cm --repository Ar reponame
Install packages from only the named repository,
irrespective of the configured
.Dq active
status from
.Pa repo.conf .
.It Fl U , Cm --no-repo-update
Suppress the automatic update of the local copy of the repository catalogue
from remote.
Automatic repository catalogue updates are only attempted when the
effective UID of the process has write access to the package database.
Otherwise they are silently ignored.
.It Fl x , Cm --regex
Treat the package names as regular expressions according to the
"modern" or "extended" syntax of
.Xr re_format 7 .
.It Fl y , Cm --yes
Assume yes when asked for confirmation before package installation.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm .
See
.Xr pkg.conf 5
for further description.
.Bl -tag -width ".Ev NO_DESCRIPTIONS"
.It Ev DEFAULT_ALWAYS_YES
.It Ev ASSUME_ALWAYS_YES
.It Ev HANDLE_RC_SCRIPTS
.It Ev PKG_CACHEDIR
.It Ev PKG_DBDIR
.It Ev REPO_AUTOUPDATE
.El
.Sh FILES
See
.Xr pkg.conf 5 .
.Sh SEE ALSO
.Xr pkg_printf 3 ,
.Xr pkg_repos 3 ,
.Xr pkg-repository 5 ,
.Xr pkg.conf 5 ,
.Xr pkg 8 ,
.Xr pkg-add 8 ,
.Xr pkg-alias 8 ,
.Xr pkg-annotate 8 ,
.Xr pkg-audit 8 ,
.Xr pkg-autoremove 8 ,
.Xr pkg-backup 8 ,
.Xr pkg-check 8 ,
.Xr pkg-clean 8 ,
.Xr pkg-config 8 ,
.Xr pkg-create 8 ,
.Xr pkg-delete 8 ,
.Xr pkg-fetch 8 ,
.Xr pkg-info 8 ,
.Xr pkg-install 8 ,
.Xr pkg-lock 8 ,
.Xr pkg-query 8 ,
.Xr pkg-register 8 ,
.Xr pkg-repo 8 ,
.Xr pkg-rquery 8 ,
.Xr pkg-search 8 ,
.Xr pkg-set 8 ,
.Xr pkg-shell 8 ,
.Xr pkg-shlib 8 ,
.Xr pkg-ssh 8 ,
.Xr pkg-stats 8 ,
.Xr pkg-update 8 ,
.Xr pkg-updating 8 ,
.Xr pkg-version 8 ,
.Xr pkg-which 8
